package com.yic.module.system.dal.mysql.logger;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.system.controller.admin.logger.vo.externallog.ExternalLogExportReqVO;
import com.yic.module.system.controller.admin.logger.vo.externallog.ExternalLogPageReqVO;
import com.yic.module.system.dal.dataobject.logger.ExternalLogDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 第三方API调用日志 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ExternalLogMapper extends BaseMapperX<ExternalLogDO> {

    default PageResult<ExternalLogDO> selectPage(ExternalLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExternalLogDO>()
                .eqIfPresent(ExternalLogDO::getSystemType, reqVO.getSystemType())
                .likeIfPresent(ExternalLogDO::getName, reqVO.getName())
                .eqIfPresent(ExternalLogDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ExternalLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ExternalLogDO::getId));
    }

    default List<ExternalLogDO> selectList(ExternalLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ExternalLogDO>()
                .eqIfPresent(ExternalLogDO::getSystemType, reqVO.getSystemType())
                .likeIfPresent(ExternalLogDO::getName, reqVO.getName())
                .eqIfPresent(ExternalLogDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(ExternalLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ExternalLogDO::getId));
    }

}
